package demo6;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 故我
 * Date: 2023-05-08
 * Time: 22:10
 */
/*class Animal implements Cloneable{
    public String name;

    //实现object类中的clone

    public Animal(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Animal{" +
                "name='" + name + '\'' +
                '}';
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}*/

class Monry{
    public double m = 9.9;
}

class Person implements Cloneable{
    public Monry monry = new Monry();

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}


public class Testdemo1 {

    public static void main(String[] args) throws CloneNotSupportedException {

    }
//    public static void main1(String[] args ) throws CloneNotSupportedException {
//
//        //这里是浅拷贝
//        Animal animal1 = new Animal("嘻嘻");
//        Animal animal2 = (Animal)animal1.clone();//返回值是一个object类
//
//        System.out.println(animal1);
//        System.out.println(animal2);
////        System.out.println(animal1.name);
////        System.out.println(animal2.name);
//    }
}
